/**
 * zmn配件模块-配件价格
 * 文件命名格式：zmn.模块名称.表名称.功能.js
 * @author DaiZhichao
 * @since 2018/10/18
 */
layui.define(['index', 'form'], function () {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;

/*    var data1 = { "code":0, "msg":"", "count":json.totalCount, "items":json.items };*/

    // 提交
    form.on('submit(zmn-part-price-form-submit)', function(obj){
        var data = obj.field;
        console.log(data);
        var url = "/part/price/addEdit.action";
        console.log(JSON.stringify(data));
        $.ajax({
            async: false,
            type: "POST",
            url: url,
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(data),
            success:function(json) {
                console.log(json);
                layer.msg(json.message);
                if(json.status == 200 && data.skuId == 0) {
                    // element.tabDelete(filter, layid);
                    zmnPage.direct("/part/price/detail.action?skuId=" + json.id,1500);
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){}
        });
        if(data.newsId * 1 > 0) {
            return false;
        }
    });

});